GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 1bb178...d86b02 )
by Marco
01:55
created

ajaxsbmt.js ➔ getquerystring   D

Complexity

Conditions 24
Paths 8

Size

Total Lines 46

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
cc 24
c 2
b 0
f 2
nc 8
nop 1
dl 0
loc 46
rs 4.7455

1 Function

Rating   Name   Duplication   Size   Complexity  
A ajaxsbmt.js ➔ ... ➔ GetElemValue 0 6 3

How to fix   Complexity   

Complexity

Complex classes like ajaxsbmt.js ➔ getquerystring often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
//##################################################################################
2
//## FORM SUBMIT WITH AJAX                                                        ##
3
//## @Author: Simone Rodriguez aka Pukos <http://www.SimoneRodriguez.com>         ##
4
//## @Version: 1.2                                                                ##
5
//## @Released: 28/08/2007                                                        ##
6
//## @License: GNU/GPL v. 2 <http://www.gnu.org/copyleft/gpl.html>                ##
7
//##################################################################################
8
9
10
function xmlhttpPost(strURL,formname,responsediv,responsemsg,scroll=false) {
11
    var xmlHttpReq = false;
12
    var self = this;
13
    // Xhr per Mozilla/Safari/Ie7
14
    if (window.XMLHttpRequest) {
15
        self.xmlHttpReq = new XMLHttpRequest();
0 ignored issues
show
Bug introduced by
The variable XMLHttpRequest seems to be never declared. If this is a global, consider adding a /** global: XMLHttpRequest */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
16
    }
17
    // per tutte le altre versioni di IE
18
    else if (window.ActiveXObject) {
19
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
0 ignored issues
show
Bug introduced by
The variable ActiveXObject seems to be never declared. If this is a global, consider adding a /** global: ActiveXObject */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
20
    }
21
    self.xmlHttpReq.open('POST', strURL, true);
22
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
23
    self.xmlHttpReq.onreadystatechange = function() {
24
        if (self.xmlHttpReq.readyState == 4) {
25
			// Quando pronta, visualizzo la risposta del form
26
            updatepage(self.xmlHttpReq.responseText,responsediv);
27
	    if (scroll) {
28
		document.getElementById(responsediv).scrollIntoView(true);
29
	    }
30
        }
31
		else{
32
			// In attesa della risposta del form visualizzo il msg di attesa
33
			updatepage(responsemsg,responsediv);
34
35
		}
36
    }
37
    self.xmlHttpReq.send(getquerystring(formname));
38
}
39
40
function getquerystring(formname) {
41
    var form = document.forms[formname];
42
	var qstr = "";
43
44
    function GetElemValue(name, value) {
45
        qstr += (qstr.length > 0 ? "&" : "")
46
            + escape(name).replace(/\+/g, "%2B") + "="
47
            + escape(value ? value : "").replace(/\+/g, "%2B");
48
			//+ escape(value ? value : "").replace(/\n/g, "%0D");
49
    }
50
	
51
	var elemArray = form.elements;
52
    for (var i = 0; i < elemArray.length; i++) {
53
        var element = elemArray[i];
54
        var elemType = element.type.toUpperCase();
55
        var elemName = element.name;
56
        if (elemName) {
57
            if (elemType == "TEXT"
58
                    || elemType == "TEXTAREA"
59
                    || elemType == "PASSWORD"
60
					|| elemType == "BUTTON"
61
					|| elemType == "RESET"
62
					|| elemType == "SUBMIT"
63
					|| elemType == "FILE"
64
					|| elemType == "IMAGE"
65
                    || elemType == "HIDDEN"
66
		    || elemType == "NUMBER"
67
		    || elemType == "DATE"
68
		    || elemType == "EMAIL")
69
                GetElemValue(elemName, element.value);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
70
            else if (elemType == "CHECKBOX" && element.checked)
71
                GetElemValue(elemName, 
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
72
                    element.value ? element.value : "On");
73
            else if (elemType == "RADIO" && element.checked)
74
                GetElemValue(elemName, element.value);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
75
            else if (elemType.indexOf("SELECT") != -1)
76
                for (var j = 0; j < element.options.length; j++) {
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
77
                    var option = element.options[j];
78
                    if (option.selected)
79
                        GetElemValue(elemName,
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
80
                            option.value ? option.value : option.text);
81
                }
82
        }
83
    }
84
    return qstr;
85
}
86
function updatepage(str,responsediv){
87
    document.getElementById(responsediv).innerHTML = str;
88
}
89